package com.pandora.loan.common.util;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author developer
 */
public class UserAgentUtil {

    public static Map<String, String> getVersionByUserAgent(String ua) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        String plat = null;
        if (ua.contains(MagicConst.AGENT_OK_HTTP)) {
            plat = "android";
        } else if (ua.contains(MagicConst.AGENT_ALAMO_FIRE)) {
            plat = "ios";
        } else {
            plat = "h5";
        }
        String v = null;
        if (!VerifyUtil.isEmpty(ua)) {
            List<String> vs = RegexUtil.findAllReg(RegexUtil.REGEX_UA_PATTEN, ua);
            if (vs != null && vs.size() > 0) {
                v = vs.get(0);
            }
        }
        map.put("_p", plat);
        map.put("_v", v);
        return map;
    }

}
